﻿using System;
using Microsoft.Xna.Framework;

namespace XTengine.ComponentModel
{
    public class ColorConverter : TypeConverter<Color>
    {
        public override Color ConvertFrom(string value)
        {
            string[] splits = value.Split(',');

            if (splits.Length < 4)
                return Color.Transparent;

            return new Color(Int32.Parse(splits[0]), Int32.Parse(splits[1]), Int32.Parse(splits[2]), Int32.Parse(splits[3]));
        }

        public override string ConvertTo(Color value)
        {
            return value.R + "," + value.G + "," + value.B + "," + value.A;
        }
    }
}